<template>
    <div>
        <ul class="mui-table-view">
				<li class="mui-table-view-cell mui-media" v-for="item in newslist" :key="item.id">
					<router-link :to="'/home/newsinfo/'+item.id">
						<img class="mui-media-object mui-pull-left" :src="item.img_url">
						<div class="mui-media-body">
							<h2>{{ item.title }}</h2>
							<p class='mui-ellipsis'>
                                <span>发表时间：{{ item.add_time | dateFormat }}</span>
                                <span>点击：{{ item.click }}次</span>
                            </p>
						</div>
					</router-link>
				</li>
				<li class="mui-table-view-cell mui-media">
					<router-link to="/home/newsinfo/2">
						<img class="mui-media-object mui-pull-left" src="https://avatar.gitee.com/uploads/30/4804430_Mikeeds.png!avatar100?1549806687">
						<div class="mui-media-body">
							<h2>幸福</h2>
							<p class='mui-ellipsis'>
                                <span>发表时间：2012-02-20 12:12:12</span>
                                <span>点击：0次</span>
                            </p>
						</div>
					</router-link>
				</li>
				<li class="mui-table-view-cell mui-media">
					<a href="javascript:;">
						<img class="mui-media-object mui-pull-left" src="https://avatar.gitee.com/uploads/30/4804430_Mikeeds.png!avatar100?1549806687">
						<div class="mui-media-body">
							<h2>幸福</h2>
							<p class='mui-ellipsis'>烤炉模式的城，到黄昏，如同打翻的调色盘一般.</p>
						</div>
					</a>
				</li>

			</ul>
    </div>
</template>

<script>
import { Toast } from 'mint-ui';

export default {
    data() {
        return {
            newslist:[]//新闻列表
        }
    },
    created(){
        this.getNewsList();
    },
    methods: {
        getNewsList(){
            this.$http.get('api/getnewslist').then(result => {
                if(result.body.status === 0){
                    // 如果没有失败，将商品列表数据保存到data上
                    this.newslist = result.body.message;
                }else{
                    Toast('获取新闻列表失败');
                }
            },(err) => {
                Toast("请求失败！");
            })
        }
    },
}
</script>

<style lang="scss" scoped>
    .mui-table-view{
        li{
            h2{
                font-size:14px;
            }
            .mui-ellipsis{
                font-size: 12px;
                color: #26a2ff;
                display: flex;
                justify-content: space-between;
            }
        }
    }
</style>